<?php

namespace Biz\model\SuperSubsidy;

use Doraemon\pockets\datebase\BaseDbModel;

/**
 * 有赞品牌信息
 */
class YouZanBrandInfoModel extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_brand_activity';

    const _DATABASE_ = 'brand_activity';

    const _TABLE_NAME = 'youzan_brand_info';


    public static function getByWhere($where, $field = '*')
    {
        return self::get($field, $where);
    }

    public static function selectByWhere($where, $select = '*')
    {
        $list = self::select($select, $where);

        return $list;
    }

    public static function selectCountWhere($where)
    {
        $count = self::count('id', $where);

        return $count;
    }


    public static function insertData($data)
    {
        if (!isset($data['created_at'])) {
            $data['created_at'] = date('Y-m-d H:i:s');
        }
        if (!isset($data['update_at'])) {
            $data['update_at'] = date('Y-m-d H:i:s');
        }
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return self::id();
    }


    public static function updateData($data, $where)
    {
        if (!isset($data['update_at'])) {
            $data['update_at'] = date('Y-m-d H:i:s');
        }
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return true;
    }
}